<include file="Public/header"/>
<include file="Public/menu"/>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/ueditor/ueditor.all.min.js"> </script>

<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            首页
            <small>营销</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="{:U('manage/index/index')}"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="{:U('special/index')}"><i class="fa fa-dashboard"></i> 专题</a></li>
            <li class="active">编辑</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content">

        <div class="row">
            <div class="col-md-12">
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title">编辑专题模板</h3>
                        <div class="box-tools">
                            <div class="btn-group pull-right" style="margin-right: 10px">
                                <a href="{:U('special/index')}" class="btn btn-sm btn-default"><i class="fa fa-list"></i>&nbsp;返回列表</a>
                            </div>
                        </div>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form action="{:U('special/edit')}" method="post" accept-charset="UTF-8" class="form-horizontal" pjax-container="" onsubmit="return checkform()">
                        <input type="hidden" name="id" value="{$info.id}">
                        <div class="box-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label" >专题标题</label>
                                <div class="col-sm-6">
                                    <div class="no-margin">
                                        <input name="title" value="{$info.title}" type="text" class="form-control" placeholder="输入 专题标题">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label" >副专题标题</label>
                                <div class="col-sm-6">
                                    <div class="no-margin">
                                        <input name="title2" value="{$info.title2}" type="text" class="form-control" placeholder="输入 副专题标题">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">分享导读</label>
                                <div class="col-sm-6">
                                    <div class="no-margin">
                                        <input name="title3" value="{$info.title3}" type="text" class="form-control" placeholder="输入 分享导读">
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">模板导读</label>
                                <div class="col-sm-6">
                                    <div class="no-margin">
                                        <textarea class="form-control" rows="3" name="title4" placeholder="输入 模板导读" >{$info.title4}</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label" for="InputPrincipal">专题活动规描述</label>
                                <div class="col-sm-6">
                                    <div class="no-margin">
                                        <input name="title5" value="{$info.title5}" type="hidden">
                                        <textarea id="container2">{$info.title5}</textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group 1">
                                <label for="image" class="col-sm-2 control-label">专题图片</label>
                                <div class="col-sm-6">
                                    <input type="file" id="image" data-max-file-count="1" />
                                    <input type="hidden" id="image_action"/>
                                </div>
                                <?php if (!empty($info['img_url'])) { ?>
                                <div class="col-sm-6" style="margin-left: 274px; margin-top: 5px;">
                                    <img src="/Uploads/{$info['img_url']}" style="height: 100px; ">
                                    <span><a class="delete_cat_img" images="img_url" href="javascript:;">删除</a></span>
                                </div>
                                <?php } ?>
                                <input type="hidden" name="img_url" id="" value="{$info['img_url']}">
                            </div>

                            <!--<div class="form-group 1">
                                <label for="image" class="col-sm-2 control-label">图标</label>
                                <div class="col-sm-6">
                                    <input type="file" id="cat_bg_img"  data-max-file-count="1" />
                                    <input type="hidden" id="cat_bg_img_action"/>
                                </div>
                                <?php if (!empty($info['ico_url'])) { ?>
                                <div class="col-sm-6" style="margin-left: 274px; margin-top: 5px;">
                                    <img src="/Uploads/{$info['ico_url']}" style="height: 100px; ">
                                    <span><a class="delete_cat_img" images="ico_url" href="javascript:;">删除</a></span>
                                </div>
                                <?php } ?>
                                <input type="hidden" name="ico_url" id="" value="{$info['ico_url']}">
                            </div>-->
                            <!--<div class="form-group">
                                <label class="col-sm-2 control-label" for="InputStatus">首页显示位置</label>
                                <div class="col-sm-6">
                                    <select class="form-control  select2-hidden-accessible" style="width: 100%;" id="Continent" name="type" tabindex="-1" aria-hidden="true">
                                        <option value="1" <if condition="$info['type'] eq 1">selected="selected"</if>">首页位置1</option>
                                    </select>
                                </div>
                            </div>-->
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <input type="hidden" name="_token" value="7lMdsZohP4DDH6f9Pvt6gn9e8TR3yOc34ovag8h3">
                            <div class="col-sm-2">

                            </div>
                            <div class="col-sm-6">

                                <div class="btn-group pull-right">
                                    <button type="submit" class="btn btn-info pull-right">提交</button>
                                </div>

                            </div>

                        </div>
                        <!-- /.box-footer -->
                    </form>
                </div>

            </div>
        </div>

    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer"/>
<link rel="stylesheet" href="/Public/admin/fileinput/fileinput.min.css">
<script src="/Public/admin/fileinput/fileinput.min.js"></script>
<script data-exec-on-popstate>
    /*var ue = UE.getEditor('container',{
        autoHeight: false,
    });
    ue.ready(function() {
        //设置编辑器的内容
        var title4 = "<?php echo $info['title4'];?>";
        ue.setContent(title4);
        //获取html内容，返回: <p>hello</p>
        //var html = ue.getContent();
        //获取纯文本内容，返回: hello
        //var txt = ue.getContentTxt();
    });*/

    var ue2 = UE.getEditor('container2',{
        autoHeight: false,
    });
    ue2.ready(function() {
        //设置编辑器的内容
        //var title5 = "<?php echo $info['title5'];?>";
        //ue2.setContent(title5);
        //获取html内容，返回: <p>hello</p>
        //var html = ue2.getContent();
        //获取纯文本内容，返回: hello
        //var txt = ue2.getContentTxt();
    });

    function checkform() {
        /*var title4 = ue.getContent();
        $('input[name=title4]').val(title4);*/

        var title5 = ue2.getContent();
        $('input[name=title5]').val(title5);

    }
    $(function () {
        // 上传图片js
        $("#image").fileinput({
            overwriteInitial: true,
            dropZoneEnabled: false,
            uploadUrl: '/admin/upload/index/"',
            language: 'zh',
            showRemove: false,
            maxFileCount: 1,
            browseClass: 'btn btn-primary btn-docup',
            showPreview: true,
            uploadClass: 'btn btn-default btn-docup',
            allowedFileTypes: ["image"],
            browseLabel: "添加图片",
            uploadLabel: "上传图片",

        }).on("fileuploaded", function (event, data, previewId, index) {
            var response = data.response;
            if (data.jqXHR.status == 200) {
                // ajax 成功返回数据写入
                //$('.file-preview-frame').eq(index).append("<input class='abc' type='hidden' name='img_url' value='"+response+"'>");
                $('input[name=img_url]').val(response);
            }
        });
        $("#image").on('filecleared', function(event) {
            $("#image_action").val(1);
        });


        $("#cat_bg_img").fileinput({
            overwriteInitial: true,
            dropZoneEnabled: false,
            uploadUrl: '/admin/upload/index/"',
            language: 'zh',
            showRemove: false,
            maxFileCount: 1,
            browseClass: 'btn btn-primary btn-docup',
            showPreview: true,
            uploadClass: 'btn btn-default btn-docup',
            allowedFileTypes: ["image"],
            browseLabel: "添加图片",
            uploadLabel: "上传图片",

        }).on("fileuploaded", function (event, data, previewId, index) {
            var response = data.response;
            if (data.jqXHR.status == 200) {
                // ajax 成功返回数据写入
                //$('.file-preview-frame').eq(index).append("<input class='abc' type='hidden' name='ico_url' value='"+response+"'>");
                $('input[name=ico_url]').val(response);
            }
        });
        $("#cat_bg_img").on('filecleared', function(event) {
            $("#cat_bg_img_action").val(1);
        });

        $(".delete_cat_img").click(function () {
            var type = $(this).attr('images');
            var this_img = $(this);
            $.get("/manage/special/deleteImg/id/{$info['id']}/type/" + type,function(data,status){
                if (data.status == true) {
                    $('input[name='+type+']').val("");
                    this_img.parent().parent().remove();
                }
            });
        });

        $('form').validate({
            rules: {
                title: {
                    required: true,
                    rangelength :[2,100]
                },
                title2: {
                    required: true,
                    rangelength :[2,200]
                },
                title3:{
                    required: true,
                    rangelength :[2,200]
                },
                title4:{
                    required: true,
                    rangelength :[2,500]
                },
                title5:{
                    required: true
                },
				start_time1:{
					required: true
				},
				end_time1:{
					required: true,
					dateTimeBigThan:"#dtp_input1"
				},
            },
            messages: {
                title: {
                    required: '专题标题必填'
                },
                title2: {
                    required: '副专题标题必填'
                },
                title3: {
                    required: '分享导读必填'
                },
                title4: {
                    required: '模板导读必填'
                },
                title5: {
                    required: '专题活动规描述'
                },
				start_time1:{
					required: "请输入开始时间",
				},
				end_time1:{
					required: "请输入结束时间",
					dateTimeBigThan: "结束时间不能小于开始时间"
				}
            }
        });
    })
</script>

